package cn.com.zcode.core.control;

import org.apache.log4j.Logger;

import cn.com.zcode.core.util.DateUtil;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class ExceptionInterceptor implements Interceptor {

	private static Logger logger = Logger.getLogger(ExceptionInterceptor.class);
	private static final long serialVersionUID = 1L;

	@Override
	public void destroy() {
		logger.info("ExceptionInterceptor destroy.....");
	}

	@Override
	public void init() {
		logger.info("ExceptionInterceptor init.....");
	}

	@Override
	public String intercept(ActionInvocation actionInvocation) throws Exception {
		try {
			actionInvocation.invoke();
		} catch (Exception e) {
			String message  ="Exception Throw ["+ DateUtil.currentDateTime()+"]";
			logger.error(message, e);
			//e.printStackTrace();
			throw e;
		}
		return null;
	}


}
